
css("text-decoration", "underline");

$('ellipse#1')
        .css({
            'fill': "#FAFE16"
        })
        .animate({
            'fill': "#FAFE16"
        }, {
            duration: 1000,
            step: function(top) {
//                                    this.setAttribute("transform", "translate(0," + top + ")");
            }
        });


function getRandomColor() {
    var letters = '0123456789ABCDEF'.split('');
    var color = '#';
    for (var i = 0; i < 6; i++) {
        color += letters[Math.floor(Math.random() * 16)];
    }
    return color;
}



wait = function() {
    var init = $('span#i').html();
    while (init == $('span#i').html()) {
    }
};

function sleepe(ms) {
    ms += new Date().getTime();
    while (new Date() < ms) {
    }
}

function sleep(millis, callback, arg) {
    setTimeout(function()
    {
        callback(arg);
    }
    , millis);
}


console.debug(g.getEdge(1, 2).connection.fg.animate({'stroke-width': 40}, 200));

oldflow = function() {
    n = Object.keys(g.nodes).length;
    animations.reset();
    c = new Array(n);
    for (i = 1; i <= n; i++) {
        c[i] = new Array(n);
        for (j = 1; j <= n; j++) {
            var edge = g.getEdge(i, j);
            if (edge) {
                c[i][j] = edge.weight;
                setEdgeLabel(edge, "0/" + edge.weight)
            } else {
                c[i][j] = 0;
            }
        }
    }

    f = new Array(n);
    for (i = 1; i <= n; i++) {
        f[i] = new Array(n);
        for (j = 1; j <= n; j++) {
            f[i][j] = 0;
        }
    }
}

oldincreaseFlow = function(path) {
    var min = c[path[0]][path[1]] - f[path[0]][path[1]];
    var i = 0;
    while (i < path.length - 1) {
        var id = path[i];
        var id2 = path[i + 1];
        var cr = c[id][id2] - f[id][id2];
        if (cr < min) {
            min = cr;
        }

        i++;
    }
    i = 0;
    while (i < path.length - 1) {
        var id = path[i];
        var id2 = path[i + 1];

        var edge;
        if (c[id][id2] > 0) {
            edge = g.getEdge(id, id2);
            addAnimu(edge, min);
        } else {
            edge = g.getEdge(id2, id);
            addAnimu(edge, -min);
        }

        f[id][id2] += min;
        f[id2][id] -= min;
        i++;
    }
    addClear();
}

oldfindPath = function() {
    var vis = new Array(n);
    var parent = new Array(n);
    for (i = 1; i <= n; i++) {
        vis[i] = 0;
    }
    var q = [];
    vis[s] = 1;
    var id = s;
    var found = false;
    while (!found && id) {
        for (var i in g.nodes[id].edges) {
            var idSasiada = g.nodes[id].edges[i].target.id;
            if (c[id][idSasiada] - f[id][idSasiada] > 0) {
                if (vis[idSasiada] === 0) {
                    vis[idSasiada] = 1;
                    parent[idSasiada] = id;
                    q.push(idSasiada);
                }
                if (idSasiada === t) {
                    found = true;
                    break;
                }
            }
            idSasiada = g.nodes[id].edges[i].source.id;
            if (c[id][idSasiada] - f[id][idSasiada] > 0) {
                if (vis[idSasiada] === 0) {
                    vis[idSasiada] = 1;
                    parent[idSasiada] = id;
                    q.push(idSasiada);
                }
                if (idSasiada === t) {
                    found = true;
                    break;
                }
            }
        }
        vis[id] = 2;
        id = q.shift();
    }
}


$("#out").html("przeplyw zwiekszany o: " + min).animate({
    opacity: 0.5}, 200).animate({
    opacity: 1}, 200);


var test = this.get("canvasPaper").rect(200, event.pageY, 100, 100);
test.toFront();
var incr = function(i, where) {

    var newI, newWhere;
    if (where === 0 && i > 490) {
        newI = i - 10;
        newWhere = 1;
    } else if (where === 1 && i < 210) {
        newI = i + 10;
        newWhere = 0;
    } else if (where === 0) {
        newI = i + 10;
        newWhere = 0;
    } else if (where === 1) {
        newI = i - 10;
        newWhere = 1;
    }

    test.animate({x: i}, 1, function() {
        incr(newI, newWhere);
    });
};
incr(210, 0);